package com.hzncc.flowable_diboot.vo;

import com.diboot.core.binding.annotation.BindDict;
import com.diboot.core.binding.annotation.BindEntityList;
import com.diboot.core.binding.annotation.BindField;
import com.diboot.core.binding.annotation.BindFieldList;
import com.diboot.core.vo.FileVO;
import com.diboot.core.vo.LabelValue;
import com.diboot.file.entity.FileRecord;
import com.diboot.iam.entity.IamOrg;
import com.diboot.iam.entity.IamUser;
import com.hzncc.flowable_diboot.entity.Business;
import com.hzncc.flowable_diboot.entity.Customer;
import com.hzncc.flowable_diboot.entity.OppoFlowOrder;
import com.hzncc.flowable_diboot.entity.OppoFlowTemplate;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;

import java.util.List;
/**
* 商机 VO定义
* @author MyName
* @version 1.0
* @date 2024-06-14
* Copyright © MyCorp
*/
@Getter @Setter @Accessors(chain = true)
public class BusinessListVO extends Business  {
private static final long serialVersionUID = 1882535590983536790L;
    /**
    * SAP客户号 关联信息
    */

    @BindField(
        entity = Customer.class,
        field = "sn",
        condition = "this.customerId = id"
     )
    private String sapNo;

    /**
    * 客户id 关联信息
    */

    @BindField(
        entity = Customer.class,
        field = "name",
        condition = "this.customer_id = id"
     )
    private String customerIdLabel;

    /**
    * 负责人 关联信息
    */

    @BindField(
        entity = IamUser.class,
        field = "realname",
        condition = "this.uid = id"
     )
    private String uidLabel;

    /**
    * 所属部门 关联信息
    */

    @BindField(
        entity = IamOrg.class,
        field = "name",
       condition = "this.uid = dbt_iam_user.id and dbt_iam_user.org_id = id"
     )
    private String dept;

    /**
    * 产品 关联文件信息
    */
    @BindEntityList(entity = FileRecord.class, condition = "this.production = id", splitBy = ",")
    private List<FileVO> productionFiles;

    @BindFieldList(
        entity = IamUser.class,
        field = "id",
        condition = "this.id = mdl_business_iam_user.business and mdl_business_iam_user.user = id"
    )
    private List<String> starUids;

    /**
    * 关注人 关联信息
    */
    @BindFieldList(
        entity = IamUser.class,
        field = "realname",
        condition = "this.id = mdl_business_iam_user.business and mdl_business_iam_user.user = id"
     )
    private List<String> starUidsLabel;

    /**
    * 模板id 关联信息
    */

    @BindField(
        entity = OppoFlowTemplate.class,
        field = "code",
        condition = "this.flow_template_id = id"
     )
    private String flowTemplateIdLabel;

    /**
    * 流程状态 关联字典选项
    */
    @BindDict(
    type = "oppoFlowStatus",
    field = "status"
    )
    private LabelValue statusLabel;

    /**
    * 流程单id 关联信息
    */

    @BindField(
        entity = OppoFlowOrder.class,
        field = "code",
        condition = "this.order_id = id"
     )
    private String orderIdLabel;

    /**
    * 赢单状态 关联字典选项
    */
    @BindDict(
    type = "businessStatus",
    field = "winType"
    )
    private LabelValue winTypeLabel;

    /**
    * 创建人 关联信息
    */

    @BindField(
        entity = IamUser.class,
        field = "realname",
        condition = "this.create_by = id"
     )
    private String createByLabel;

    /**
    * 更新人 关联信息
    */

    @BindField(
        entity = IamUser.class,
        field = "realname",
        condition = "this.update_by = id"
     )
    private String updateByLabel;

    private int isStar;
}